{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from fastai.basics import *\n",
    "from fastai.callback.all import *\n",
    "from fastai.text.all import *"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# all_slow"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Tutorial - Assemble the data on the wikitext dataset\n",
    "\n",
    "> Using `Datasets`, `Pipeline`, `TfmdLists` and `Transform` in text"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this tutorial, we explore the mid-level API for data collection in the text application. We will use the bases introduced in the [pets tutorial](http://docs.fast.ai/tutorial.pets) so you should be familiar with `Transform`, `Pipeline`, `TfmdLists` and `Datasets` already."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "path = untar_data(URLs.WIKITEXT_TINY)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The dataset comes with the articles in two csv files, so we read it and concatenate them in one dataframe."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "df_train = pd.read_csv(path/'train.csv', header=None)\n",
    "df_valid = pd.read_csv(path/'test.csv', header=None)\n",
    "df_all = pd.concat([df_train, df_valid])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>0</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>\\n = 2013 – 14 York City F.C. season = \\n \\n The 2013 – 14 season was the &lt;unk&gt; season of competitive association football and 77th season in the Football League played by York City Football Club , a professional football club based in York , North Yorkshire , England . Their 17th @-@ place finish in 2012 – 13 meant it was their second consecutive season in League Two . The season ran from 1 July 2013 to 30 June 2014 . \\n Nigel Worthington , starting his first full season as York manager , made eight permanent summer signings . By the turn of the year York were only above the relegation z...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>\\n = Big Boy ( song ) = \\n \\n \" Big Boy \" &lt;unk&gt; \" I 'm A Big Boy Now \" was the first single ever recorded by the Jackson 5 , which was released by Steeltown Records in January 1968 . The group played instruments on many of their Steeltown compositions , including \" Big Boy \" . The song was neither a critical nor commercial success , but the Jackson family were delighted with the outcome nonetheless . \\n The Jackson 5 would release a second single with Steeltown Records before moving to Motown Records . The group 's recordings at Steeltown Records were thought to be lost , but they were re...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>\\n = The Remix ( Lady Gaga album ) = \\n \\n The Remix is a remix album by American recording artist Lady Gaga . Released in Japan on March 3 , 2010 , it contains remixes of the songs from her first studio album , The Fame ( 2008 ) , and her third extended play , The Fame Monster ( 2009 ) . A revised version of the track list was prepared for release in additional markets , beginning with Mexico on May 3 , 2010 . A number of recording artists have produced the songs , including Pet Shop Boys , Passion Pit and The Sound of Arrows . The remixed versions feature both uptempo and &lt;unk&gt; composit...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>\\n = New Year 's Eve ( Up All Night ) = \\n \\n \" New Year 's Eve \" is the twelfth episode of the first season of the American comedy television series Up All Night . The episode originally aired on NBC in the United States on January 12 , 2012 . It was written by Erica &lt;unk&gt; and was directed by Beth McCarthy @-@ Miller . The episode also featured a guest appearance from Jason Lee as Chris and Reagan 's neighbor and Ava 's boyfriend , Kevin . \\n During Reagan ( Christina Applegate ) and Chris 's ( Will &lt;unk&gt; ) first New Year 's Eve game night , Reagan 's competitiveness comes out causing Ch...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>\\n = Geopyxis carbonaria = \\n \\n Geopyxis carbonaria is a species of fungus in the genus Geopyxis , family &lt;unk&gt; . First described to science in 1805 , and given its current name in 1889 , the species is commonly known as the charcoal loving elf @-@ cup , dwarf &lt;unk&gt; cup , &lt;unk&gt; &lt;unk&gt; cup , or pixie cup . The small , &lt;unk&gt; @-@ shaped fruitbodies of the fungus are reddish @-@ brown with a whitish fringe and measure up to 2 cm ( 0 @.@ 8 in ) across . They have a short , tapered stalk . Fruitbodies are commonly found on soil where brush has recently been burned , sometimes in great numbers ....</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         0\n",
       "0   \\n = 2013 – 14 York City F.C. season = \\n \\n The 2013 – 14 season was the <unk> season of competitive association football and 77th season in the Football League played by York City Football Club , a professional football club based in York , North Yorkshire , England . Their 17th @-@ place finish in 2012 – 13 meant it was their second consecutive season in League Two . The season ran from 1 July 2013 to 30 June 2014 . \\n Nigel Worthington , starting his first full season as York manager , made eight permanent summer signings . By the turn of the year York were only above the relegation z...\n",
       "1   \\n = Big Boy ( song ) = \\n \\n \" Big Boy \" <unk> \" I 'm A Big Boy Now \" was the first single ever recorded by the Jackson 5 , which was released by Steeltown Records in January 1968 . The group played instruments on many of their Steeltown compositions , including \" Big Boy \" . The song was neither a critical nor commercial success , but the Jackson family were delighted with the outcome nonetheless . \\n The Jackson 5 would release a second single with Steeltown Records before moving to Motown Records . The group 's recordings at Steeltown Records were thought to be lost , but they were re...\n",
       "2   \\n = The Remix ( Lady Gaga album ) = \\n \\n The Remix is a remix album by American recording artist Lady Gaga . Released in Japan on March 3 , 2010 , it contains remixes of the songs from her first studio album , The Fame ( 2008 ) , and her third extended play , The Fame Monster ( 2009 ) . A revised version of the track list was prepared for release in additional markets , beginning with Mexico on May 3 , 2010 . A number of recording artists have produced the songs , including Pet Shop Boys , Passion Pit and The Sound of Arrows . The remixed versions feature both uptempo and <unk> composit...\n",
       "3   \\n = New Year 's Eve ( Up All Night ) = \\n \\n \" New Year 's Eve \" is the twelfth episode of the first season of the American comedy television series Up All Night . The episode originally aired on NBC in the United States on January 12 , 2012 . It was written by Erica <unk> and was directed by Beth McCarthy @-@ Miller . The episode also featured a guest appearance from Jason Lee as Chris and Reagan 's neighbor and Ava 's boyfriend , Kevin . \\n During Reagan ( Christina Applegate ) and Chris 's ( Will <unk> ) first New Year 's Eve game night , Reagan 's competitiveness comes out causing Ch...\n",
       "4   \\n = Geopyxis carbonaria = \\n \\n Geopyxis carbonaria is a species of fungus in the genus Geopyxis , family <unk> . First described to science in 1805 , and given its current name in 1889 , the species is commonly known as the charcoal loving elf @-@ cup , dwarf <unk> cup , <unk> <unk> cup , or pixie cup . The small , <unk> @-@ shaped fruitbodies of the fungus are reddish @-@ brown with a whitish fringe and measure up to 2 cm ( 0 @.@ 8 in ) across . They have a short , tapered stalk . Fruitbodies are commonly found on soil where brush has recently been burned , sometimes in great numbers ...."
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_all.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([' \\n = Ireland = \\n \\n Ireland ( / <unk> / ; Irish : <unk> [ <unk> ] ; Ulster @-@ Scots : <unk> [ <unk> ] ) is an island in the North Atlantic . It is separated from Great Britain to its east by the North Channel , the Irish Sea , and St George \\'s Channel . Ireland is the second @-@ largest island of the British Isles , the third @-@ largest in Europe , and the twentieth @-@ largest on Earth . \\n <unk> , Ireland is divided between the Republic of Ireland ( officially named Ireland ) , which covers five @-@ <unk> of the island , and Northern Ireland , which is part of the United Kingdom , in the northeast of the island . In 2011 the population of Ireland was about 6 @.@ 4 million , ranking it the second @-@ most populous island in Europe after Great Britain . Just under 4 @.@ 6 million live in the Republic of Ireland and just over 1 @.@ 8 million live in Northern Ireland . \\n The island \\'s geography comprises relatively low @-@ lying mountains surrounding a central plain , with several navigable rivers extending inland . The island has lush vegetation , a product of its mild but changeable climate which avoids extremes in temperature . <unk> woodlands covered the island until the Middle Ages . As of 2013 , the amount of land that is wooded in Ireland is about 11 % of the total , compared with a European average of 35 % . There are twenty @-@ six extant mammal species native to Ireland . The Irish climate is very moderated and classified as oceanic . As a result , winters are <unk> than expected for such a northerly area . However , summers are cooler than those in Continental Europe . Rainfall and cloud cover are abundant . \\n The earliest evidence of human presence in Ireland is dated at 10 @,@ 500 BC . Gaelic Ireland had emerged by the 1st century AD and lasted until the First World War . The island was <unk> from the 5th century onward . Following the Norman invasion in the 12th century , England claimed sovereignty over Ireland . However , English rule did not extend over the whole island until the 16th – 17th century Tudor conquest , which led to colonisation by settlers from Britain . In the <unk> , a system of Protestant English rule was designed to materially disadvantage the Catholic majority and Protestant dissenters , and was extended during the 18th century . With the Acts of Union in 1801 , Ireland became a part of the United Kingdom . A war of independence in the early 20th century was followed by the partition of the island , creating the Irish Free State , which became increasingly sovereign over the following decades , and Northern Ireland , which remained a part of the United Kingdom . Northern Ireland saw much civil unrest from the late 1960s until the 1990s . This subsided following a political agreement in 1998 . In 1973 the Republic of Ireland joined the European Economic Community while the United Kingdom , and Northern Ireland , as part of it , did the same . \\n Irish culture has had a significant influence on other cultures , especially in the fields of literature . Alongside mainstream Western culture , a strong indigenous culture exists , as expressed through Gaelic games , Irish music , and the Irish language . The culture of the island also shares many features with that of Great Britain , including the English language , and sports such as association football , rugby , horse racing , and golf . \\n \\n = = Name = = \\n \\n Ireland consists of Old Irish <unk> + English land . <unk> derives from Proto @-@ Celtic * <unk> ( compare Welsh <unk> ) , which is also the source of Latin <unk> . <unk> derives from a root meaning \" fat , prosperous \" . \\n \\n = = History = = \\n \\n \\n = = = Prehistoric Ireland = = = \\n \\n During the last glacial period , and up until about 9000 years ago , most of Ireland was covered with ice , most of the time . Sea levels were lower and Ireland , like Great Britain , formed part of continental Europe . By 12 @,@ 000 BC , rising sea levels due to ice melting caused Ireland to become separated from Great Britain . Later , around <unk> BC , Great Britain itself became separated from continental Europe . The earliest evidence of human presence in Ireland is dated at 10 @,@ 500 BC . Until recently the earliest evidence of humans in Ireland were Mesolithic people who arrived by boat from Britain between 8000 BC and 7000 BC . \\n From about <unk> BC , Neolithic settlers arrived introducing cereal <unk> , a housing culture ( similar to those of the same period in Scotland ) and stone monuments . A more advanced agriculture was to develop . At the <unk> Fields , preserved beneath a blanket of peat in present @-@ day County Mayo , is an extensive field system , arguably the oldest in the world , dating from not long after this period . <unk> of small divisions separated by dry @-@ stone walls , the fields were farmed for several centuries between <unk> BC and 3000 BC . <unk> and barley were the principal crops imported from the Iberian Peninsula . \\n The Bronze Age – defined by the use of metal – began around 2500 BC , with technology changing people \\'s everyday lives during this period through innovations such as the wheel , <unk> oxen , weaving textiles , <unk> alcohol , and skilful <unk> , which produced new weapons and tools , along with fine gold decoration and jewellery , such as brooches and <unk> . According to John T. Koch and others , Ireland in the Late Bronze Age was part of a maritime trading @-@ <unk> culture called the Atlantic Bronze Age that also included Britain , western France and Iberia , and that this is where Celtic languages developed . This contrasts with the traditional view that their origin lies in mainland Europe with the <unk> culture . \\n \\n = = = = <unk> of Celtic Ireland = = = = \\n \\n During the Iron Age , a Celtic language and culture emerged in Ireland . How and when the island of Ireland became Celtic has been debated for close to a century , with the migrations of the Celts being one of the more enduring themes of archaeological and linguistic studies . Today , there is more than one school of thought on how this occurred in Ireland . \\n The long @-@ standing traditional view , once widely accepted , is that Celtic language , <unk> script and culture were brought to Ireland by waves of invading or migrating Celts from mainland Europe . This theory draws on the <unk> <unk> <unk> , a medieval Christian pseudo @-@ history of Ireland along with the presence of Celtic culture , language and artefacts found in Ireland such as Celtic bronze <unk> , shields , <unk> and other finely crafted Celtic associated possessions . The theory holds that there were four separate Celtic invasions of Ireland . The <unk> were said to be the first , followed by the <unk> from northern Gaul and Britain . Later , <unk> tribes from <unk> ( present @-@ day Brittany ) were said to have invaded Ireland and Britain more or less simultaneously . Lastly , the <unk> ( <unk> ) were said to have reached Ireland from either northern Iberia or southern Gaul . It was claimed that a second wave named the <unk> , belonging to the <unk> people of northern Gaul , began arriving about the sixth century BC . They were said to have given their name to the island . \\n A more recent theory , with broad support among archaeologists , is that Celtic culture and language arrived in Ireland as a result of cultural <unk> . This theory proposes that the <unk> of Ireland may have been the culmination of a long process of social and economic interaction between Ireland , Britain and adjacent parts of Continental Europe . \\n The theory was advanced in part because of lack of archeological evidence for large @-@ scale Celtic immigration , though it is accepted that such movements are notoriously difficult to identify . Some proponents of this theory hold that it is likely that there was migration of smaller groups of Celts to Ireland , with sufficiently regular traffic to constitute a \" migration stream , \" but that this was not the fundamental cause of Insular <unk> . Historical linguists are <unk> that this method alone could account for the absorption of the Celtic language , with some saying that an assumed processional view of Celtic linguistic formation is \\' an especially hazardous exercise \\' . Genetic lineage investigation into the area of Celtic migration to Ireland has led to findings that showed no significant differences in mitochondrial DNA between Ireland and large areas of continental Europe , in contrast to parts of the Y @-@ chromosome pattern . When taking both into account a recent study drew the conclusion that modern Celtic speakers in Ireland could be thought of as European \" Atlantic Celts \" showing a shared ancestry throughout the Atlantic zone from northern Iberia to western Scandinavia rather than substantially central European . \\n \\n = = = Late antiquity and early medieval times = = = \\n \\n The earliest written records of Ireland come from classical Greco @-@ Roman <unk> . Ptolemy in his <unk> refers to Ireland as <unk> <unk> ( Little Britain ) , in contrast to the larger island , which he called <unk> <unk> ( Great Britain ) . In his later work , Geography , Ptolemy refers to Ireland as <unk> and to Great Britain as Albion . These \" new \" names were likely to have been the local names for the islands at the time . The earlier names , in contrast , were likely to have been coined before direct contact with local peoples was made . \\n The Romans would later refer to Ireland by this name too in its <unk> form , <unk> , or Scotia . Ptolemy records sixteen nations inhabiting every part of Ireland in 100 AD . The relationship between the Roman Empire and the kingdoms of ancient Ireland is unclear . However , a number of finds of Roman coins have been made , for example at the Iron Age settlement of <unk> Hill near <unk> and <unk> . \\n Ireland continued as a <unk> of rival kingdoms but , beginning in the 7th century AD , a concept of national kingship gradually became articulated through the concept of a High King of Ireland . Medieval Irish literature portrays an almost unbroken sequence of High Kings stretching back thousands of years but modern historians believe the scheme was constructed in the 8th century to justify the status of powerful political groupings by projecting the origins of their rule into the remote past . \\n The High King was said to <unk> over the provincial kingdoms that together formed Ireland . All of these kingdoms had their own kings but were at least nominally subject to the High King . The High King was drawn from the ranks of the provincial kings and ruled also the royal kingdom of Meath , with a ceremonial capital at the Hill of Tara . The concept only became a political reality in the Viking Age and even then was not a consistent one . Ireland did have a culturally <unk> rule of law : the early written judicial system , the <unk> Laws , administered by a professional class of jurists known as the <unk> . However , a united kingdom of Gaelic Ireland was never achieved . \\n The Chronicle of Ireland records that in <unk> AD Bishop <unk> arrived in Ireland on a mission from Pope Celestine I to minister to the Irish \" already believing in Christ \" . The same chronicle records that Saint Patrick , Ireland \\'s best known patron saint , arrived the following year . There is continued debate over the missions of <unk> and Patrick but the consensus is that they both took place and that the older <unk> tradition collapsed in the face of the new religion . Irish Christian scholars excelled in the study of Latin and Greek learning and Christian theology . In the monastic culture that followed the Christianisation of Ireland , Latin and Greek learning was preserved in Ireland during the Early Middle Ages in contrast to elsewhere in Europe , where the Dark Ages followed the decline of the Roman Empire . \\n The arts of manuscript illumination , <unk> and sculpture flourished and produced treasures such as the Book of Kells , ornate jewellery and the many carved stone crosses that still dot the island today . A mission founded in <unk> on Iona by the Irish monk Saint Columba began a tradition of Irish missionary work that spread Celtic Christianity and learning to Scotland , England and the Frankish Empire on Continental Europe after the fall of Rome . These missions continued until the late Middle Ages , establishing monasteries and centres of learning , producing scholars such as <unk> <unk> and Johannes <unk> and <unk> much influence in Europe . \\n From the 9th century , waves of Viking raiders plundered Irish monasteries and towns . These raids added to a pattern of raiding and endemic warfare that was already deep @-@ seated in Ireland . The Vikings also were involved in establishing most of the major coastal settlements in Ireland : Dublin , Limerick , Cork , Wexford , Waterford , and also <unk> , <unk> , <unk> , <unk> , <unk> , <unk> Foyle and <unk> <unk> . \\n \\n = = = Norman and English invasions = = = \\n \\n On 1 May <unk> , an expedition of <unk> @-@ Norman knights with an army of about six hundred landed at <unk> Strand in present @-@ day County Wexford . It was led by Richard de Clare , called <unk> due to his prowess as an archer . The invasion , which coincided with a period of renewed Norman expansion , was at the invitation of <unk> Mac <unk> , the king of Leinster . \\n In 1166 , Mac <unk> had fled to <unk> , France , following a war involving <unk> Ua <unk> , of <unk> , and sought the assistance of the <unk> king , Henry II , in <unk> his kingdom . In <unk> , Henry arrived in Ireland in order to review the general progress of the expedition . He wanted to re @-@ exert royal authority over the invasion which was expanding beyond his control . Henry successfully re @-@ imposed his authority over <unk> and the <unk> @-@ Norman <unk> and persuaded many of the Irish kings to accept him as their overlord , an arrangement confirmed in the 1175 Treaty of Windsor . \\n The invasion was <unk> by the provisions of the Papal Bull <unk> , issued by Adrian IV in 1155 . The bull encouraged Henry to take control in Ireland in order to oversee the financial and administrative reorganisation of the Irish Church and its integration into the Roman Church system . Some restructuring had already begun at the ecclesiastical level following the <unk> of Kells in <unk> . There has been significant controversy regarding the authenticity of <unk> , and there is no general agreement as to whether the bull was genuine or a forgery . \\n In <unk> , the new pope , Alexander III , further encouraged Henry to advance the integration of the Irish Church with Rome . Henry was authorised to impose a <unk> of one <unk> per hearth as an annual contribution . This church levy , called Peter \\'s <unk> , is extant in Ireland as a voluntary donation . In turn , Henry accepted the title of Lord of Ireland which Henry conferred on his younger son , John <unk> , in <unk> . This defined the Irish state as the Lordship of Ireland . When Henry \\'s successor died unexpectedly in <unk> , John inherited the crown of England and retained the Lordship of Ireland . \\n Over the century that followed , Norman feudal law gradually replaced the Gaelic <unk> Law so that by the late 13th century the Norman @-@ Irish had established a feudal system throughout much of Ireland . Norman settlements were characterised by the establishment of <unk> , <unk> , towns and the seeds of the modern county system . A version of the Magna <unk> ( the Great Charter of Ireland ) , <unk> Dublin for London and Irish Church for Church of England , was published in 1216 and the Parliament of Ireland was founded in <unk> . \\n From the mid @-@ 14th century , after the Black Death , Norman settlements in Ireland went into a period of decline . The Norman rulers and the Gaelic Irish <unk> <unk> and the areas under Norman rule became <unk> . In some parts , a hybrid Hiberno @-@ Norman culture emerged . In response , the Irish parliament passed the <unk> of Kilkenny in <unk> . These were a set of laws designed to prevent the <unk> of the <unk> into Irish society by requiring English subjects in Ireland to speak English , follow English customs and abide by English law . \\n By the end of the 15th century central English authority in Ireland had all but disappeared and a renewed Irish culture and language , albeit with Norman influences , was dominant again . English Crown control remained relatively <unk> in an <unk> foothold around Dublin known as The <unk> , and under the provisions of <unk> \\' Law of <unk> , the Irish Parliamentary legislation was subject to the approval of the English Parliament . \\n \\n = = = The Kingdom of Ireland = = = \\n \\n The title of King of Ireland was re @-@ created in 1542 by Henry VIII , then King of England , of the Tudor dynasty . English rule of law was reinforced and expanded in Ireland during the latter part of the 16th century , leading to the Tudor conquest of Ireland . A near complete conquest was achieved by the turn of the 17th century , following the Nine Years \\' War and the Flight of the Earls . \\n This control was further consolidated during the wars and conflicts of the 17th century , which witnessed English and Scottish colonisation in the <unk> of Ireland , the Wars of the Three Kingdoms and the <unk> War . Irish losses during the Wars of the Three Kingdoms ( which , in Ireland , included the Irish Confederacy and the <unk> conquest of Ireland ) are estimated to include 20 @,@ 000 battlefield casualties . 200 @,@ 000 civilians are estimated to have died as a result of a combination of war @-@ related famine , displacement , guerrilla activity and pestilence over the duration of the war . A further 50 @,@ 000 were sent into indentured servitude in the West Indies . Some historians estimate that as much as half of the pre @-@ war population of Ireland may have died as a result of the conflict . \\n The religious struggles of the 17th century left a deep sectarian division in Ireland . Religious allegiance now determined the perception in law of loyalty to the Irish King and Parliament . After the passing of the Test Act 1672 , and with the victory of the forces of the dual monarchy of William and Mary over the <unk> , Roman Catholics and <unk> Protestant Dissenters were barred from sitting as members in the Irish Parliament . Under the emerging <unk> Laws , Irish Roman Catholics and Dissenters were increasingly deprived of various and <unk> civil rights even to the ownership of hereditary property . Additional <unk> punitive legislation followed 1703 , <unk> and <unk> . This completed a comprehensive systemic effort to materially disadvantage Roman Catholics and Protestant Dissenters , while <unk> a new ruling class of Anglican conformists . The new Anglo @-@ Irish ruling class became known as the Protestant <unk> . \\n An extraordinary climatic shock known as the \" Great Frost \" struck Ireland and the rest of Europe between December <unk> and September 1741 , after a decade of relatively mild winters . The winters destroyed stored crops of potatoes and other staples and the poor summers severely damaged <unk> . This resulted in the famine of 1740 . An estimated 250 @,@ 000 people ( about one in eight of the population ) died from the ensuing pestilence and disease . The Irish government halted export of corn and kept the army in quarters but did little more . Local <unk> and charitable organisations provided relief but could do little to prevent the ensuing mortality . \\n In the aftermath of the famine , an increase in industrial production and a surge in trade brought a succession of construction booms . The population soared in the latter part of this century and the architectural legacy of Georgian Ireland was built . In 1782 , <unk> \\' Law was repealed , giving Ireland legislative independence from Great Britain for the first time since <unk> . The British government , however , still retained the right to nominate the government of Ireland without the consent of the Irish parliament . \\n \\n = = = Union with Great Britain = = = \\n \\n In 1798 , members of the Protestant <unk> tradition ( mainly Presbyterian ) made common cause with Roman Catholics in a republican rebellion inspired and led by the Society of United <unk> , with the aim of creating an independent Ireland . Despite assistance from France the rebellion was put down by British and Irish government and yeomanry forces . In 1800 , the British and Irish parliaments both passed Acts of Union that , with effect from 1 January 1801 , merged the Kingdom of Ireland and the Kingdom of Great Britain to create a United Kingdom of Great Britain and Ireland . \\n The passage of the Act in the Irish Parliament was ultimately achieved with substantial <unk> , having failed on the first attempt in <unk> . According to contemporary documents and historical analysis , this was achieved through a considerable degree of bribery , with funding provided by the British Secret Service Office , and the <unk> of <unk> , places and honours to secure votes . Thus , the parliament in Ireland was abolished and replaced by a united parliament at Westminster in London , though resistance remained , as evidenced by Robert Emmet \\'s failed Irish Rebellion of 1803 . \\n Aside from the development of the linen industry , Ireland was largely passed over by the industrial revolution , partly because it lacked coal and iron resources and partly because of the impact of the sudden union with the structurally superior economy of England , which saw Ireland as a source of agricultural produce and capital . \\n The Great Famine of the 1840s caused the deaths of one million Irish people and over a million more emigrated to escape it . By the end of the decade , half of all immigration to the United States was from Ireland . The period of civil unrest that followed until the end of the 19th century is referred to as the Land War . Mass emigration became deeply entrenched and the population continued to decline until the mid @-@ 20th century . Immediately prior to the famine the population was recorded as 8 @.@ 2 million by the 1841 census . The population has never returned to this level since . The population continued to fall until 1961 and it was not until the 2006 census that the last county of Ireland ( County <unk> ) to record a rise in population since 1841 did so . \\n The 19th and early 20th centuries saw the rise of modern Irish nationalism , primarily among the Roman Catholic population . The pre @-@ eminent Irish political figure after the Union was Daniel O \\'Connell . He was elected as Member of Parliament for Ennis in a surprise result and despite being unable to take his seat as a Roman Catholic . O \\'Connell spearheaded a vigorous campaign that was taken up by the Prime Minister , the Irish @-@ born soldier and statesman , the Duke of Wellington . <unk> the Catholic Relief Bill through Parliament , aided by future prime minister Robert Peel , Wellington prevailed upon a reluctant George IV to sign the Bill and proclaim it into law . George \\'s father had opposed the plan of the earlier Prime Minister , Pitt the Younger , to introduce such a bill following the Union of 1801 , fearing Catholic <unk> to be in conflict with the Act of Settlement 1701 . \\n Daniel O \\'Connell led a subsequent campaign , for the repeal of the Act of Union , which failed . Later in the century , Charles Stewart <unk> and others campaigned for autonomy within the Union , or \" Home Rule \" . <unk> , especially those located in Ulster , were strongly opposed to Home Rule , which they thought would be dominated by Catholic interests . After several attempts to pass a Home Rule bill through parliament , it looked certain that one would finally pass in 1914 . To prevent this from happening , the Ulster Volunteers were formed in 1913 under the leadership of Edward Carson . \\n Their formation was followed in 1914 by the establishment of the Irish Volunteers , whose aim was to ensure that the Home Rule Bill was passed . The Act was passed but with the \" temporary \" exclusion of the six counties of Ulster that would become Northern Ireland . Before it could be implemented , however , the Act was suspended for the duration of the First World War . The Irish Volunteers split into two groups . The majority , approximately 175 @,@ 000 in number , under John <unk> , took the name National Volunteers and supported Irish involvement in the war . A minority , approximately 13 @,@ 000 , retained the Irish Volunteers \\' name , and opposed Ireland \\'s involvement in the war . \\n The Easter Rising of 1916 was carried out by the latter group together with a smaller socialist militia , the Irish Citizen Army . The British response , executing fifteen leaders of the Rising over a period of ten days and <unk> or <unk> more than a thousand people , turned the mood of the country in favour of the rebels . Support for Irish <unk> increased further due to the ongoing war in Europe , as well as the Conscription Crisis of 1918 . \\n The pro @-@ independence republican party , <unk> <unk> , received overwhelming endorsement in the general election of 1918 , and in 1919 proclaimed an Irish Republic , setting up its own parliament ( Dáil <unk> ) and government . Simultaneously the Volunteers , which became known as the Irish Republican Army ( IRA ) , launched a three @-@ year guerrilla war , which ended in a truce in July 1921 ( although violence continued until June 1922 , mostly in Northern Ireland ) . \\n \\n = = = Partition = = = \\n \\n In December 1921 , the Anglo @-@ Irish Treaty was concluded between the British Government and representatives of the Second Dáil . It gave Ireland complete independence in its home affairs and practical independence for foreign policy , but an opt @-@ out clause allowed Northern Ireland to remain within the United Kingdom , which it immediately exercised as expected . Additionally , an oath of allegiance to the King was to be taken . <unk> over these provisions led to a split in the nationalist movement and a subsequent Irish Civil War between the new government of the Irish Free State and those opposed to the treaty , led by <unk> de Valera . The civil war officially ended in May 1923 when de Valera issued a cease @-@ fire order . \\n \\n = = = = Independence = = = = \\n \\n During its first decade , the newly formed Irish Free State was governed by the victors of the civil war . When de Valera achieved power , he took advantage of the <unk> of Westminster and political circumstances to build upon <unk> to greater sovereignty made by the previous government . The oath was abolished and in 1937 a new constitution was adopted . This completed a process of gradual separation from the British Empire that governments had pursued since independence . However , it was not until 1949 that the state was declared , officially , to be the Republic of Ireland . \\n The state was neutral during World War II , but offered clandestine assistance to the Allies , particularly in the potential defence of Northern Ireland . Despite their country \\'s neutrality , approximately 50 @,@ 000 volunteers from independent Ireland joined the British forces during the war , four being awarded Victoria Crosses . \\n The <unk> was also active in Ireland . German intelligence operations effectively ended in September 1941 when police made arrests on the basis of surveillance carried out on the key diplomatic <unk> in Dublin , including that of the United States . To the authorities , <unk> was a fundamental line of defence . With a regular army of only slightly over seven thousand men at the start of the war , and with limited supplies of modern weapons , the state would have had great difficulty in defending itself from invasion from either side in the conflict . \\n Large @-@ scale emigration marked most of the post @-@ WWII period ( particularly during the 1950s and 1980s ) , but beginning in 1987 the economy improved , and the 1990s saw the beginning of substantial economic growth . This period of growth became known as the Celtic Tiger . The Republic \\'s real GDP grew by an average of 9 @.@ 6 % per annum between 1995 and 1999 , in which year the Republic joined the euro . In 2000 , it was the sixth @-@ richest country in the world in terms of GDP per capita . \\n Social changes also occurred in this time , most markedly with the decline in authority of the Catholic Church . The financial crisis that began in 2008 dramatically ended this period of boom . GDP fell by 3 % in 2008 and by 7 @.@ 1 % in 2009 , the worst year since records began ( although earnings by foreign @-@ owned businesses continued to grow ) . The state has since experienced deep recession , with unemployment , which doubled during 2009 , remaining above 14 % in 2012 . \\n \\n = = = = Northern Ireland = = = = \\n \\n Northern Ireland was created as a division of the United Kingdom by the Government of Ireland Act 1920 and until 1972 it was a self @-@ governing jurisdiction within the United Kingdom with its own parliament and prime minister . Northern Ireland , as part of the United Kingdom , was not neutral during the Second World War and Belfast suffered four bombing raids in 1941 . Conscription was not extended to Northern Ireland and roughly an equal number volunteered from Northern Ireland as volunteered from the south . One , James Joseph <unk> , received the Victoria Cross for <unk> . \\n Although Northern Ireland was largely spared the <unk> of the civil war , in decades that followed partition there were sporadic episodes of inter @-@ communal violence . Nationalists , mainly Roman Catholic , wanted to unite Ireland as an independent republic , whereas unionists , mainly Protestant , wanted Northern Ireland to remain in the United Kingdom . The Protestant and Catholic communities in Northern Ireland voted largely along sectarian lines , meaning that the Government of Northern Ireland ( elected by \" first @-@ past @-@ the @-@ post \" from 1929 ) was controlled by the Ulster Unionist Party . Over time , the minority Catholic community felt increasingly alienated with further <unk> fuelled by practices such as <unk> and discrimination in housing and employment . \\n In the late 1960s , nationalist grievances were aired publicly in mass civil rights protests , which were often confronted by loyalist counter @-@ protests . The government \\'s reaction to confrontations was seen to be one @-@ sided and heavy @-@ handed in favour of unionists . Law and order broke down as unrest and inter @-@ communal violence increased . The Northern Ireland government requested the British Army to aid the police , who were exhausted after several nights of serious rioting . In 1969 , the paramilitary Provisional IRA , which favoured the creation of a united Ireland , emerged from a split in the Irish Republican Army and began a campaign against what it called the \" British occupation of the six counties \" . \\n Other groups , on both the unionist side and the nationalist side , participated in violence and a period known as the Troubles began . Over 3 @,@ 600 deaths resulted over the subsequent three decades of conflict . Owing to the civil unrest during the Troubles , the British government suspended home rule in 1972 and imposed direct rule . There were several unsuccessful attempts to end the Troubles politically , such as the <unk> Agreement of 1973 . In 1998 , following a ceasefire by the Provisional IRA and multi @-@ party talks , the Good Friday Agreement was concluded as a treaty between the British and Irish governments , <unk> the text agreed in the multi @-@ party talks . \\n The substance of the Agreement ( formally referred to as the Belfast Agreement ) was later endorsed by <unk> in both parts of Ireland . The Agreement restored self @-@ government to Northern Ireland on the basis of power @-@ sharing in a regional Executive drawn from the major parties in a new Northern Ireland Assembly , with entrenched <unk> for the two main communities . The Executive is jointly headed by a First Minister and deputy First Minister drawn from the unionist and nationalist parties . Violence had decreased greatly after the Provisional IRA and loyalist <unk> in 1994 and in 2005 the Provisional IRA announced the end of its armed campaign and an independent commission supervised its <unk> and that of other nationalist and unionist paramilitary organisations . \\n The Assembly and power @-@ sharing Executive were suspended several times but were restored again in 2007 . In that year the British government officially ended its military support of the police in Northern Ireland ( Operation Banner ) and began withdrawing troops . On 27 June 2012 , Northern Ireland \\'s deputy first minister and former IRA commander , Martin McGuinness , shook hands with Queen Elizabeth II in Belfast , symbolising reconciliation between the two sides . \\n \\n = = Politics = = \\n \\n <unk> , the island is divided between the Republic of Ireland , an independent state , and Northern Ireland ( a constituent country of the United Kingdom ) . They share an open border and both are part of the Common Travel Area . \\n Both the Republic of Ireland and the United Kingdom are members of the European Union , and as a consequence there is free movement of people , goods , services and capital across the border . \\n \\n = = = Republic of Ireland = = = \\n \\n The Republic of Ireland is a parliamentary democracy based on the British model , with a written constitution and a popularly elected president who has mostly ceremonial powers . The government is headed by a prime minister , the <unk> , who is appointed by the President on the nomination of the lower house of parliament , the Dáil . Members of the government are chosen from both the Dáil and the upper house of parliament , the <unk> . Its capital is Dublin . \\n The Republic today ranks amongst the wealthiest countries in the world in terms of GDP per capita and in 2012 was ranked the seventh most developed nation in the world by the United Nations \\' Human Development Index . A period of rapid economic expansion from 1995 onwards became known as the Celtic Tiger period , was brought to an end in 2008 with an unprecedented financial crisis and an economic depression in 2009 . \\n \\n = = = Northern Ireland = = = \\n \\n Northern Ireland is a part of the United Kingdom with a local executive and assembly which exercise devolved powers . The executive is jointly headed by the first and deputy @-@ first minister , with the <unk> being allocated in proportion with each party \\'s representation in the assembly . Its capital is Belfast . \\n Ultimately political power is held by the UK government , from which Northern Ireland has gone through intermittent periods of direct rule during which devolved powers have been suspended . Northern Ireland elects 18 of the UK House of Commons \\' 650 MPs . The Northern Ireland Secretary is a cabinet @-@ level post in the British government . \\n Along with England , Wales and Scotland , Northern Ireland forms one of the three separate legal jurisdictions of the UK , all of which share the Supreme Court of the United Kingdom as their court of final appeal . \\n \\n = = = All @-@ island institutions = = = \\n \\n As part of the Good Friday Agreement , the British and Irish governments agreed on the creation of all @-@ island institutions and areas of cooperation . \\n The North / South <unk> Council is an institution through which ministers from the Government of Ireland and the Northern Ireland Executive agree all @-@ island policies . At least six of these policy areas must have an associated all @-@ island \" implementation bodies \" and at least six others must be implemented separately in each jurisdiction . The implementation bodies are : Waterways Ireland , the Food Safety Promotion Board , <unk> , the Special European Union Programmes Body , the North / South Language Body and the Foyle , <unk> and Irish Lights Commission . \\n The British – Irish <unk> Conference provides for co @-@ operation between the Government of Ireland and the Government of the United Kingdom on all matter of mutual interest , especially Northern Ireland . In light of the Republic \\'s particular interest in the governance of Northern Ireland , \" regular and frequent \" meetings co @-@ chaired by the <unk> Minister for Foreign Affairs and the UK Secretary of State for Northern Ireland , dealing with non @-@ devolved matters to do with Northern Ireland and non @-@ devolved all @-@ Ireland issues , are required to take place under the establishing treaty . \\n The North / South Inter @-@ Parliamentary Association is a joint parliamentary forum for the island of Ireland . It has no formal powers but operates as a forum for discussing matters of common concern between the respective legislatures . \\n \\n = = Economy = = \\n \\n Despite the two jurisdictions using two distinct currencies ( the euro and pound sterling ) , a growing amount of commercial activity is carried out on an all @-@ Ireland basis . This has been facilitated by the two jurisdictions \\' shared membership of the European Union , and there have been calls from members of the business community and <unk> for the creation of an \" all @-@ Ireland economy \" to take advantage of economies of scale and boost competitiveness . \\n There are two multi @-@ city regions on the island of Ireland : \\n Dublin @-@ Belfast corridor - 3 @.@ 3 m \\n Cork @-@ Limerick @-@ Galway corridor - 1 m \\n Below is a comparison of the Regional GDP on the island of Ireland . \\n The BMW region of the Republic of Ireland ( consisting of <unk> , Counties <unk> , <unk> , <unk> , Longford , Donegal , Monaghan , <unk> , <unk> ) \\n The S & E region of the Republic of Ireland ( consisting of Munster , Counties Dublin , <unk> , Meath , Kildare , Kilkenny , <unk> , Wexford ) . \\n \\n = = = Energy = = = \\n \\n Ireland has an ancient industry based on peat ( known locally as \" turf \" ) as a source of energy for home fires . A form of <unk> energy , this source of heat is still widely used in rural areas . However , due to the ecological importance of <unk> in storing carbon and their rarity , the EU is attempting to protect this habitat by fining Ireland if they are dug up . In cities , heat is generally supplied by heating oil , although some urban suppliers distribute \" <unk> of turf \" as \" <unk> fuel \" . \\n An area in which the island operates as a single market is electricity . For much of their existence electricity networks in the Republic of Ireland and Northern Ireland were entirely separate . Both networks were designed and constructed independently post partition . However , as a result of changes over recent years they are now connected with three <unk> and also connected through Great Britain to mainland Europe . The situation in Northern Ireland is complicated by the issue of private companies not supplying Northern Ireland Electricity ( <unk> ) with enough power . In the Republic of Ireland , the <unk> has failed to <unk> its power stations and the availability of power plants has recently averaged only 66 % , one of the worst such rates in Western Europe . <unk> is building a <unk> transmission line between Ireland and Great Britain with a capacity of 500 MW , about 10 % of Ireland \\'s peak demand . \\n As with electricity , the natural gas distribution network is also now all @-@ island , with a pipeline linking <unk> , County Meath , and <unk> , County Antrim completed in 2007 . Most of Ireland \\'s gas comes through <unk> between <unk> in Scotland and <unk> , County Antrim and <unk> , County Dublin . A decreasing supply is coming from the <unk> gas field off the County Cork coast and the <unk> Gas Field off the coast of County Mayo has yet to come on @-@ line . The County Mayo field is facing some localised opposition over a controversial decision to refine the gas onshore . \\n The Republic of Ireland has shown a strong commitment to renewable energy , ranking as one of the top 10 markets for <unk> investment in the 2014 Global Green Economy Index . Research and development in Ireland in renewable energy such as wind power has increased since 2004 . Large wind farms are being constructed in coastal counties such as Cork , Donegal , Mayo and Antrim . The construction of wind farms has in some cases been delayed by opposition from local communities , some of whom overall consider the wind turbines to be <unk> . The Republic of Ireland is also hindered by an ageing network that was not designed to handle the varying availability of power that comes from wind farms . The <unk> \\'s <unk> Hill facility is the only power @-@ storage facility in the state . \\n \\n = = Geography = = \\n \\n The island of Ireland is located in the north @-@ west of Europe , between latitudes 51 ° and 56 ° N , and <unk> 11 ° and 5 ° W. It is separated from the neighbouring island of Great Britain by the Irish Sea and the North Channel , which has a width of 23 kilometres ( 14 mi ) at its <unk> point . To the west is the northern Atlantic Ocean and to the south is the Celtic Sea , which lies between Ireland and Brittany , in France . Ireland has a total area of 84 @,@ <unk> km2 ( 32 @,@ 595 sq mi ) . Ireland and Great Britain , together with many nearby smaller islands , are known collectively as the British Isles . As the term British Isles is controversial in relation to Ireland , the alternate term Britain and Ireland is often used as a neutral term for the islands . \\n A ring of coastal mountains surround low plains at the centre of the island . The highest of these is <unk> ( Irish : <unk> <unk> ) in County Kerry , which rises to 1 @,@ <unk> m ( 3 @,@ 406 ft ) above sea level . The most arable land lies in the province of Leinster . Western areas can be mountainous and rocky with green panoramic <unk> . The River Shannon , the island \\'s longest river at 386 km ( 240 mi ) long , rises in County <unk> in the north west and flows 113 kilometres ( 70 mi ) to Limerick city in the mid west . \\n The island \\'s lush vegetation , a product of its mild climate and frequent rainfall , earns it the sobriquet the Emerald Isle . Overall , Ireland has a mild but changeable oceanic climate with few extremes . The climate is typically insular and is temperate avoiding the extremes in temperature of many other areas in the world at similar latitudes . This is a result of the <unk> moist winds which ordinarily prevail from the South @-@ Western Atlantic . \\n Precipitation falls throughout the year but is light overall , particularly in the east . The west tends to be wetter on average and prone to Atlantic storms , especially in the late autumn and winter months . These occasionally bring destructive winds and higher total rainfall to these areas , as well as sometimes snow and hail . The regions of north County Galway and east County Mayo have the highest incidents of recorded lightning annually for the island , with lightning occurring approximately five to ten days per year in these areas . Munster , in the south , records the least snow whereas Ulster , in the north , records the most . \\n Inland areas are warmer in summer and colder in winter . Usually around 40 days of the year are below freezing 0 ° C ( 32 ° F ) at inland weather stations , compared to 10 days at coastal stations . Ireland is sometimes affected by heat waves , most recently in 1995 , 2003 , 2006 and 2013 . In common with the rest of Europe , Ireland experienced unusually cold weather during the winter of 2009 / 10 . Temperatures fell as low as − 17 @.@ 2 ° C ( 1 ° F ) in County Mayo on 20 December and up to a metre ( 3 ft ) of snow fell in mountainous areas . \\n The island consists of varied geological provinces . In the far west , around County Galway and County Donegal , is a medium to high grade <unk> and igneous complex of <unk> affinity , similar to the Scottish Highlands . Across southeast Ulster and extending southwest to Longford and south to <unk> is a province of Ordovician and <unk> rocks , with similarities to the Southern <unk> province of Scotland . Further south , along the County Wexford coastline , is an area of granite <unk> into more Ordovician and <unk> rocks , like that found in Wales . \\n In the southwest , around <unk> Bay and the mountains of <unk> \\'s <unk> , is an area of substantially deformed , but only lightly <unk> , Devonian @-@ aged rocks . This partial ring of \" hard rock \" geology is covered by a blanket of <unk> limestone over the centre of the country , giving rise to a comparatively fertile and lush landscape . The west @-@ coast district of the <unk> around <unk> has well @-@ developed <unk> features . Significant <unk> lead @-@ zinc <unk> is found in the <unk> around <unk> and <unk> . \\n <unk> exploration is ongoing following the first major find at the <unk> Head gas field off Cork in the mid @-@ 1970s . In 1999 , economically significant finds of natural gas were made in the <unk> Gas Field off the County Mayo coast . This has increased activity off the west coast in parallel with the \" West of Shetland \" step @-@ out development from the North Sea <unk> province . The <unk> oil field , estimated to contain over 28 million barrels ( 4 @,@ 500 @,@ 000 m3 ) of oil , is another recent discovery . \\n <unk> \\n \\n = = = Places of interest = = = \\n \\n There are three World Heritage Sites on the island : the <unk> na <unk> , <unk> Michael and the Giant \\'s Causeway . A number of other places are on the tentative list , for example the <unk> , the <unk> Fields and Mount Stewart . \\n Some of the most visited sites in Ireland include <unk> Castle , the Rock of <unk> , the <unk> of <unk> , Holy Cross Abbey and <unk> Castle . Historically important monastic sites include <unk> and Clonmacnoise , which are maintained as national monuments in the Republic of Ireland . \\n Dublin is the most heavily <unk> region and home to several of the most popular attractions such as the Guinness <unk> and Book of Kells . The west and south west , which includes the Lakes of Killarney and the <unk> peninsula in County Kerry and <unk> and the <unk> Islands in County Galway , are also popular tourist destinations . \\n <unk> Island lies off the coast of County Mayo and is Ireland \\'s largest island . It is a popular tourist destination for surfing and contains 5 Blue Flag beaches and <unk> one of the worlds highest sea cliffs . <unk> homes , built during the 17th , 18th and 19th centuries in <unk> , <unk> and neo @-@ Gothic styles , such as , Castle Ward , <unk> House , <unk> House , <unk> Castle are also of interest to tourists . Some have been converted into hotels , such as <unk> Castle , Castle Leslie and <unk> Castle . \\n World Heritage Sites \\n \\n = = Flora and fauna = = \\n \\n Because Ireland became isolated from mainland Europe by rising sea levels before the last ice age had completely finished , it has fewer land animal and plant species than Great Britain , which separated later , or mainland Europe . There are 55 mammal species in Ireland and of them only 26 land mammal species are considered native to Ireland . Some species , such as , the red fox , <unk> and <unk> , are very common , whereas others , like the Irish hare , red deer and pine <unk> are less so . <unk> wildlife , such as species of sea turtle , shark , seal , whale , and <unk> , are common off the coast . About 400 species of birds have been recorded in Ireland . Many of these are migratory , including the barn swallow . \\n Several different habitat types are found in Ireland , including farmland , open woodland , temperate broadleaf and mixed forests , conifer plantations , peat <unk> and a variety of coastal habitats . However , agriculture drives current land use patterns in Ireland , limiting natural habitat preserves , particularly for larger wild mammals with greater territorial needs . With no large apex predators in Ireland other than humans and dogs , such populations of animals as semi @-@ wild deer that cannot be controlled by smaller predators , such as the fox , are controlled by annual culling . \\n There are no snakes in Ireland and only one species of reptile ( the common lizard ) is native to the island . Extinct species include the Irish elk , the great <unk> and the wolf . Some previously extinct birds , such as the golden eagle , been reintroduced in about the year 2000 after decades of <unk> . Until medieval times Ireland was heavily forested with oak , pine and birch . <unk> today cover about 12 @.@ 6 % of Ireland , of which 4 @,@ 450 km ² or one million acres is owned by <unk> , the Republic \\'s forestry service . \\n As of 2012 the Republic is one of the least forested countries in Europe . Much of the land is now covered with pasture and there are many species of wild @-@ flower . <unk> ( <unk> europaeus ) , a wild <unk> , is commonly found growing in the <unk> and <unk> are plentiful in the more moist regions , especially in the western parts . It is home to hundreds of plant species , some of them unique to the island , and has been \" invaded \" by some grasses , such as <unk> <unk> . \\n The algal and seaweed flora is that of the cold @-@ temperate variety . The total number of species is <unk> and is distributed as follows : \\n 264 <unk> ( red algae ) \\n 152 <unk> ( brown algae including <unk> ) \\n 114 <unk> ( green algae ) \\n 31 <unk> ( Blue @-@ green algae ) \\n <unk> species include : \\n <unk> <unk> ( <unk> ) <unk> & Guiry \\n <unk> <unk> <unk> & Guiry \\n <unk> <unk> <unk> & Guiry \\n <unk> <unk> Rico & Guiry \\n <unk> <unk> <unk> & <unk> ex <unk> . \\n The island has been invaded by some algae , some of which are now well established . For example : \\n <unk> <unk> Harvey , which originated in Australia and was first recorded by M. De Valera in 1939 \\n <unk> <unk> <unk> , which is now locally abundant and first recorded in the 1930s \\n <unk> <unk> ( <unk> ) <unk> , now well established in a number of localities on the south , west , and north @-@ east coasts \\n <unk> fragile ssp. fragile ( formerly reported as ssp. <unk> ) , now well established . \\n <unk> fragile ssp. <unk> has been established to be native , although for many years it was regarded as an alien species . \\n Because of its mild climate , many species , including sub @-@ tropical species such as palm trees , are grown in Ireland . <unk> , Ireland belongs to the Atlantic European province of the <unk> Region within the <unk> Kingdom . The island itself can be subdivided into two <unk> : the Celtic broadleaf forests and North Atlantic moist mixed forests . \\n \\n = = = Impact of agriculture = = = \\n \\n The long history of agricultural production , coupled with modern intensive agricultural methods such as <unk> and fertiliser use and runoff from <unk> into streams , rivers and lakes , impact the natural fresh @-@ water ecosystems and have placed pressure on biodiversity in Ireland . \\n A land of green fields for crop cultivation and cattle rearing limits the space available for the establishment of native wild species . <unk> , however , traditionally used for maintaining and <unk> land boundaries , act as a refuge for native wild flora . This ecosystem stretches across the countryside and acts as a network of connections to preserve remnants of the ecosystem that once covered the island . <unk> under the Common Agricultural Policy , which supported agricultural practices that preserved <unk> environments , are undergoing reforms . The Common Agricultural Policy had in the past <unk> potentially destructive agricultural practices , for example by emphasising production without placing limits on indiscriminate use of <unk> and <unk> ; but reforms have gradually <unk> subsidies from production levels and introduced environmental and other requirements . \\n Forest covers about 12 @.@ 6 % of the country , most of it designated for commercial production . Forested areas typically consist of <unk> plantations of non @-@ native species , which may result in habitats that are not suitable for supporting native species of invertebrates . Remnants of native forest can be found scattered around the island , in particular in the Killarney National Park . Natural areas require fencing to prevent over @-@ grazing by deer and sheep that <unk> over <unk> areas . <unk> in this manner is one of the main factors preventing the natural regeneration of forests across many regions of the country . \\n \\n = = Demographics = = \\n \\n People have lived in Ireland for over 9 @,@ 000 years . The different eras are termed <unk> , <unk> , Bronze Age , and Iron Age . \\n Early historical and genealogical records note the existence of major groups such as the <unk> , <unk> <unk> , Dál Riata , <unk> , <unk> , <unk> , <unk> , <unk> , Ulaid . <unk> later major groups included the <unk> , <unk> , <unk> . \\n Smaller groups included the <unk> ( see <unk> ) , <unk> , <unk> , <unk> , <unk> , <unk> , <unk> , Fir <unk> , <unk> , <unk> , <unk> , <unk> , <unk> , <unk> , <unk> , <unk> , Uí Maine , Uí <unk> . Many survived into late medieval times , others vanished as they became politically unimportant . \\n Over the past 1200 years , Vikings , <unk> , Welsh , <unk> , Scots , English , Africans , Eastern Europeans and South Americans have all added to the population and have had significant influences on Irish culture . \\n Ireland \\'s largest religious group is Christianity . The largest denomination is Roman Catholicism representing over 73 % for the island ( and about 87 % of the Republic of Ireland ) . Most of the rest of the population <unk> to one of the various Protestant denominations ( about 48 % of Northern Ireland ) . The largest is the Anglican Church of Ireland . The Muslim community is growing in Ireland , mostly through increased immigration , with a 50 % increase in the republic between the 2006 and 2011 census . The island has a small Jewish community . About 4 % of the Republic \\'s population and about 14 % of the Northern Ireland population describe themselves as of no religion . In a 2010 survey conducted on behalf of the Irish Times , 32 % of <unk> said they went to a religious service more than once a week . \\n The population of Ireland rose rapidly from the 16th century until the mid @-@ 19th century , but a devastating famine in the 1840s caused one million deaths and forced over one million more to <unk> in its immediate wake . Over the following century the population was reduced by over half , at a time when the general trend in European countries was for populations to rise by an average of three @-@ fold . \\n \\n = = = Divisions and settlements = = = \\n \\n Traditionally , Ireland is subdivided into four provinces : <unk> ( west ) , Leinster ( east ) , Munster ( south ) , and Ulster ( north ) . In a system that developed between the 13th and 17th centuries , Ireland has 32 traditional counties . Twenty @-@ six of these counties are in the Republic of Ireland and six are in Northern Ireland . The six counties that constitute Northern Ireland are all in the province of Ulster ( which has nine counties in total ) . As such , Ulster is often used as a synonym for Northern Ireland , although the two are not <unk> . \\n In the Republic of Ireland , counties form the basis of the system of local government . Counties Dublin , Cork , Limerick , Galway , Waterford and <unk> have been broken up into smaller administrative areas . However , they are still treated as counties for cultural and some official purposes , for example postal addresses and by the Ordnance Survey Ireland . Counties in Northern Ireland are no longer used for local governmental purposes , but , as in the Republic , their traditional boundaries are still used for informal purposes such as sports leagues and in cultural or tourism contexts . \\n City status in Ireland is decided by legislative or royal charter . Dublin , with over 1 million residents in the Greater Dublin Area , is the largest city on the island . Belfast , with <unk> @,@ <unk> residents , is the largest city in Northern Ireland . City status does not directly <unk> with population size . For example , Armagh , with 14 @,@ 590 is the seat of the Church of Ireland and the Roman Catholic <unk> of All Ireland and was re @-@ granted city status by Queen Elizabeth II in 1994 ( having lost that status in local government reforms of 1840 ) . In the Republic of Ireland , Kilkenny , seat of the Butler dynasty , while no longer a city for administrative purposes ( since the 2001 Local Government Act ) , is entitled by law to continue to use the description . \\n \\n = = = Migration = = = \\n \\n The population of Ireland collapsed dramatically during the second half of the 19th century . A population of over 8 million in 1841 was reduced to slightly more than 4 million by 1921 . In part , the fall in population was due to death from the Great Famine of 1845 to 1852 , which took about 1 million lives . However , by far the greater cause of population decline was the dire economic state of the country which led to an entrenched culture of emigration lasting until the 21st century . \\n Emigration from Ireland in the 19th century contributed to the populations of England , the United States , Canada and Australia , where a large Irish diaspora lives . As of 2006 , 4 @.@ 3 million Canadians , or 14 % of the population , are of Irish descent . As of 2013 , a total of 34 @.@ 5 million Americans claim Irish ancestry . \\n With growing prosperity since the last decade of the 20th century , Ireland became a destination for immigrants . Since the European Union expanded to include Poland in 2004 , Polish people have made up the largest number of immigrants ( over 150 @,@ 000 ) from Central Europe . There has also been significant immigration from Lithuania , the Czech Republic and Latvia . \\n The Republic of Ireland in particular has seen large @-@ scale immigration , with 420 @,@ 000 foreign <unk> as of 2006 , about 10 % of the population . A quarter of births ( 24 percent ) in 2009 were to mothers born outside Ireland . Chinese and <unk> , along with people from other African countries , have accounted for a large proportion of the non – European Union migrants to Ireland . Up to 50 @,@ 000 eastern and central European migrant workers left Ireland in response to the Irish financial crisis . \\n \\n = = = Languages = = = \\n \\n Two main languages are spoken in Ireland : Irish and English . Both languages have widely contributed to literature . Irish , now a minority but official language of the Republic of Ireland , was the vernacular of the Irish people for over two thousand years and was probably introduced by some sort of proto @-@ Gaelic migration during the Iron Age , possibly earlier . It began to be written down after Christianisation in the 5th century and spread to Scotland and the Isle of Man where it evolved into the Scottish Gaelic and <unk> languages respectively . \\n The Irish language has a vast treasure of written texts from many centuries , and is divided by linguists into Old Irish from the 6th to 10th century , Middle Irish from the 10th to 13th century , Early Modern Irish until the 17th century , and the Modern Irish spoken today . It remained the dominant language of Ireland for most of those periods , having influences from Latin , Old Norse , French and English . It declined under British rule but remained the majority tongue until the early 19th century , and since then has been a minority language , although revival efforts are continuing in both the Republic of Ireland and Northern Ireland . \\n Gaeltacht or Irish @-@ speaking areas are still seeing a decline in the language . The main Gaeltacht areas are down the west of the country , in Donegal , Mayo , Galway and Kerry with smaller Gaeltacht areas near <unk> in Waterford , <unk> , in Meath , and the Shaw \\'s Road in Belfast . Irish language is a compulsory subject in the state education system in the Republic , and the <unk> movement has seen many Irish medium schools established in both jurisdictions . \\n English was first introduced to Ireland in the Norman invasion . It was spoken by a few peasants and merchants brought over from England , and was largely replaced by Irish before the Tudor Conquest of Ireland . It was introduced as the official language with the Tudor and <unk> conquests . The Ulster plantations gave it a permanent foothold in Ulster , and it remained the official and upper @-@ class language elsewhere , the Irish @-@ speaking chieftains and nobility having been deposed . Language shift during the 19th century replaced Irish with English as the first language for a vast majority of the population . \\n Less than 10 % of the population of the Republic of Ireland today speak Irish regularly outside of the education system and 38 % of those over 15 years are classified as \" Irish speakers \" . In Northern Ireland , English is the de facto official language , but official recognition is afforded to Irish , including specific protective measures under Part III of the European Charter for Regional or <unk> Languages . A lesser status ( including recognition under Part II of the Charter ) is given to Ulster Scots dialects , which are spoken by roughly 2 % of Northern Ireland residents , and also spoken by some in the Republic of Ireland . Since the 1960s with the increase in immigration , many more languages have been introduced , particularly deriving from Asia and Eastern Europe . \\n \\n = = Culture = = \\n \\n Ireland \\'s culture comprises elements of the culture of ancient peoples , later immigrant and broadcast cultural influences ( chiefly Gaelic culture , <unk> , <unk> and aspects of broader European culture ) . In broad terms , Ireland is regarded as one of the Celtic nations of Europe , alongside Scotland , Wales , Cornwall , Isle of Man and Brittany . This combination of cultural influences is visible in the intricate designs termed Irish interlace or Celtic <unk> . These can be seen in the ornamentation of medieval religious and secular works . The style is still popular today in jewellery and graphic art , as is the distinctive style of traditional Irish music and dance , and has become indicative of modern \" Celtic \" culture in general . \\n Religion has played a significant role in the cultural life of the island since ancient times ( and since the 17th century plantations , has been the focus of political identity and divisions on the island ) . Ireland \\'s pre @-@ Christian heritage fused with the Celtic Church following the missions of Saint Patrick in the 5th century . The Hiberno @-@ Scottish missions , begun by the Irish monk Saint Columba , spread the Irish vision of Christianity to pagan England and the Frankish Empire . These missions brought written language to an illiterate population of Europe during the Dark Ages that followed the fall of Rome , earning Ireland the sobriquet , \" the island of saints and scholars \" . \\n Since the 20th century the Irish <unk> worldwide have become , especially those with a full range of cultural and <unk> offerings , outposts of Irish culture . \\n The Republic of Ireland \\'s national theatre is the Abbey Theatre , which was founded in 1904 , and the national Irish @-@ language theatre is An <unk> , which was established in 1928 in Galway . <unk> such as <unk> O <unk> , Brian <unk> , Sebastian Barry , <unk> McPherson and Billy Roche are internationally renowned . \\n \\n = = = Arts = = = \\n \\n Ireland has made a large contribution to world literature in all its branches , particularly in the English language . Poetry in Irish is among the oldest vernacular poetry in Europe , with the earliest examples dating from the 6th century . In English , Jonathan Swift , still often called the foremost <unk> in the English language , was very popular in his day for works such as <unk> \\'s <unk> and A Modest <unk> , and Oscar Wilde is known most for his often quoted witticisms . \\n In the 20th century , Ireland produced four winners of the Nobel Prize for Literature : George Bernard Shaw , William Butler Yeats , Samuel <unk> and Seamus Heaney . Although not a Nobel Prize winner , James Joyce is widely considered to be one of the most significant writers of the 20th century . Joyce \\'s 1922 novel Ulysses is considered one of the most important works of <unk> literature and his life is celebrated annually on 16 June in Dublin as \" <unk> \" . Modern Irish literature is often connected with its rural heritage through writers such as John <unk> and poets such as Seamus Heaney . \\n Music has been in evidence in Ireland since prehistoric times . Although in the early Middle Ages the church was \" quite unlike its counterpart in continental Europe \" , there was considerable interchange between monastic settlements in Ireland and the rest of Europe that contributed to what is known as Gregorian chant . Outside religious establishments , musical genres in early Gaelic Ireland are referred to as a triad of weeping music ( <unk> ) , laughing music ( <unk> ) and sleeping music ( <unk> ) . Vocal and instrumental music ( e.g. for the <unk> , pipes , and various string instruments ) was transmitted orally , but the Irish <unk> , in particular , was of such significance that it became Ireland \\'s national symbol . Classical music following European models first developed in urban areas , in establishments of Anglo @-@ Irish rule such as Dublin Castle , St Patrick \\'s Cathedral and Christ Church as well as the country houses of the Anglo @-@ Irish ascendancy , with the first performance of Handel \\'s <unk> ( 1742 ) being among the highlights of the <unk> era . In the 19th century , public concerts provided access to classical music to all classes of society . Yet , for political and financial reasons Ireland has been too small to provide a living to many musicians , so the names of the better @-@ known Irish composers of this time belong to emigrants . \\n Irish traditional music and dance has seen a surge in popularity and global coverage since the 1960s . In the middle years of the 20th century , as Irish society was <unk> , traditional music had fallen out of favour , especially in urban areas . However during the 1960s , there was a revival of interest in Irish traditional music led by groups such as The Dubliners , The <unk> , The Wolfe Tones , the Clancy Brothers , <unk> \\'s Men and individuals like <unk> <unk> <unk> and Christy Moore . Groups and musicians including <unk> , Van Morrison and <unk> <unk> incorporated elements of Irish traditional music into contemporary rock music and , during the 1970s and 1980s , the distinction between traditional and rock musicians became blurred , with many individuals regularly crossing over between these styles of playing . This trend can be seen more recently in the work of artists like <unk> , The Saw Doctors , The <unk> , <unk> O \\'Connor , <unk> , The <unk> and The <unk> among others . Since then there have been a number of stylistic <unk> including folk metal and others , while some contemporary music groups stick closer to a \" traditional \" sound . \\n The earliest known Irish graphic art and sculpture are Neolithic carvings found at sites such as <unk> and is traced through Bronze age artefacts and the religious carvings and illuminated manuscripts of the medieval period . During the course of the 19th and 20th centuries , a strong tradition of painting emerged , including such figures as John Butler Yeats , William <unk> , Jack Yeats and Louis le <unk> . Contemporary Irish visual artists of note include Sean Scully , Kevin <unk> , and Alice <unk> . \\n \\n = = = Science = = = \\n \\n The Irish philosopher and theologian Johannes Scotus <unk> was considered one of the leading intellectuals of his early Middle Ages . Sir Ernest Henry <unk> , an Irish explorer , was one of the principal figures of Antarctic exploration . He , along with his expedition , made the first ascent of Mount <unk> and the discovery of the approximate location of the South Magnetic Pole . Robert Boyle was a 17th @-@ century natural philosopher , chemist , physicist , inventor and early gentleman scientist . He is largely regarded one of the founders of modern chemistry and is best known for the formulation of Boyle \\'s law . \\n 19th century physicist , John Tyndall , discovered the Tyndall effect . Father Nicholas Joseph <unk> , Professor of Natural Philosophy in <unk> College , is best known for his invention of the induction coil , <unk> and he discovered an early method of <unk> in the 19th century . \\n Other notable Irish physicists include Ernest Walton , winner of the 1951 Nobel Prize in Physics . With Sir John Douglas <unk> , he was the first to split the nucleus of the atom by artificial means and made contributions to the development of a new theory of wave equation . William Thomson , or Lord Kelvin , is the person whom the absolute temperature unit , the Kelvin , is named after . Sir Joseph <unk> , a physicist and mathematician , made innovations in the understanding of electricity , dynamics , <unk> and the electron theory of matter . His most influential work was <unk> and <unk> , a book on theoretical physics published in 1900 . \\n George Johnstone <unk> introduced the term electron in 1891 . John Stewart Bell was the originator of Bell \\'s <unk> and a paper concerning the discovery of the Bell @-@ <unk> @-@ <unk> anomaly and was nominated for a Nobel prize . Notable mathematicians include Sir William Rowan Hamilton , famous for work in classical mechanics and the invention of <unk> . Francis <unk> Edgeworth \\'s contribution of the Edgeworth Box remains influential in neo @-@ classical <unk> theory to this day ; while Richard <unk> inspired Adam Smith , among others . John B. <unk> was a specialist in number theory and discovered a 2000 @-@ digit prime number in 1999 and a record composite <unk> number in 2003 . John <unk> <unk> made progress in different fields of science , including mechanics and <unk> methods in general relativity . He had mathematician John Nash as one of his students . \\n Ireland has nine universities , seven in the Republic of Ireland and two in Northern Ireland , including Trinity College , Dublin and the University College Dublin , as well as numerous third @-@ level colleges and institutes and a branch of the Open University , the Open University in Ireland . \\n \\n = = = Sports = = = \\n \\n The island of Ireland fields a single international team in most sports . One notable exception to this is association football , although both associations continued to field international teams under the name \" Ireland \" until the 1950s . An all @-@ Ireland club competition for soccer , the <unk> Cup , was created in 2005 . \\n Gaelic football is the most popular sport in Ireland in terms of match attendance and community involvement , with about 2 @,@ 600 clubs on the island . In 2003 it represented 34 % of total sports <unk> at events in Ireland and abroad , followed by hurling at 23 % , soccer at 16 % and rugby at 8 % and the All @-@ Ireland Football Final is the most watched event in the sporting calendar . Soccer is the most widely played team game on the island , and the most popular in Northern Ireland . <unk> , golf , aerobics , soccer , cycling , Gaelic football and <unk> / <unk> are the sporting activities with the highest levels of playing participation . The sport is also the most notable exception where the Republic of Ireland and Northern Ireland field separate international teams . Northern Ireland has produced two World <unk> Champions . \\n Many other sports are also played and followed , including basketball , boxing , cricket , fishing , greyhound racing , <unk> , hockey , horse racing , motor sport , show jumping and tennis . \\n \\n = = = = Field sports = = = = \\n \\n Gaelic football , hurling and <unk> are the best @-@ known of the Irish traditional sports , collectively known as Gaelic games . Gaelic games are governed by the Gaelic Athletic Association ( GAA ) , with the exception of ladies \\' Gaelic football and <unk> ( women \\'s variant of hurling ) , which are governed by separate organisations . The headquarters of the GAA ( and the main stadium ) is located at the 82 @,@ 500 capacity <unk> Park in north Dublin . Many major GAA games are played there , including the semi @-@ finals and finals of the All @-@ Ireland Senior Football Championship and All @-@ Ireland Senior <unk> Championship . During the redevelopment of the Lansdowne Road stadium in 2007 – 10 , international rugby and soccer were played there . All GAA players , even at the highest level , are amateurs , receiving no wages , although they are permitted to receive a limited amount of sport @-@ related income from commercial sponsorship . \\n The Irish Football Association ( IFA ) was originally the governing body for soccer across the island . The game has been played in an organised fashion in Ireland since the 1870s , with <unk> F.C. in Belfast being Ireland \\'s oldest club . It was most popular , especially in its first decades , around Belfast and in Ulster . However , some clubs based outside Belfast thought that the IFA largely favoured Ulster @-@ based clubs in such matters as selection for the national team . In 1921 , following an incident in which , despite an earlier promise , the IFA moved an Irish Cup semi @-@ final replay from Dublin to Belfast , Dublin @-@ based clubs broke away to form the Football Association of the Irish Free State . Today the southern association is known as the Football Association of Ireland ( FAI ) . Despite being initially <unk> by the Home Nations \\' associations , the FAI was recognised by FIFA in 1923 and organised its first international fixture in 1926 ( against Italy ) . However , both the IFA and FAI continued to select their teams from the whole of Ireland , with some players earning international caps for matches with both teams . Both also referred to their respective teams as Ireland . \\n In 1950 , FIFA directed the associations only to select players from within their respective territories and , in 1953 , directed that the FAI \\'s team be known only as \" Republic of Ireland \" and that the IFA \\'s team be known as \" Northern Ireland \" ( with certain exceptions ) . Northern Ireland qualified for the World Cup finals in 1958 ( reaching the quarter @-@ finals ) , 1982 and 1986 . The Republic qualified for the World Cup finals in 1990 ( reaching the quarter @-@ finals ) , 1994 , 2002 and the European Championships in 1988 and 2012 . Across Ireland , there is significant interest in the English and , to a lesser extent , Scottish soccer leagues . \\n Unlike soccer , Ireland continues to field a single national rugby team and a single association , the Irish Rugby Football Union ( <unk> ) , governs the sport across the island . The Irish rugby team have played in every Rugby World Cup , making the quarter @-@ finals in four of them . Ireland also hosted games during the 1991 and the 1999 Rugby World Cups ( including a quarter @-@ final ) . There are four professional Irish teams ; all four play in the <unk> League ( now called the <unk> <unk> ) and at least three compete for the <unk> Cup . Irish rugby has become increasingly competitive at both the international and provincial levels since the sport went professional in 1994 . During that time , Ulster ( 1999 ) , Munster ( 2006 and 2008 ) and Leinster ( 2009 , 2011 and 2012 ) have won the <unk> Cup . In addition to this , the Irish International side has had increased success in the Six Nations Championship against the other European elite sides . This success , including Triple Crowns in 2004 , 2006 and 2007 , culminated with a clean sweep of victories , known as a Grand Slam , in 2009 . \\n \\n = = = = Other sports = = = = \\n \\n Horse racing and greyhound racing are both popular in Ireland . There are frequent horse race meetings and greyhound stadiums are well @-@ attended . The island is noted for the breeding and training of race horses and is also a large exporter of racing dogs . The horse racing sector is largely concentrated in the County Kildare . \\n Irish athletics has seen a heightened success rate since the year 2000 , with Sonia O <unk> winning two medals at 5 @,@ 000 metres on the track ; gold at the 1995 World Championships and silver at the 2000 Sydney Olympics . Gillian O <unk> won silver in the <unk> walk at the 2003 World Championships , while sprint <unk> <unk> O \\'Rourke won gold at the 2006 World Indoor Championship in Moscow . Olive <unk> won a silver medal in the <unk> walk in the World Athletics Championships in Berlin in 2009 . \\n Ireland has won more medals in boxing than in any other Olympic sport . Boxing is governed by the Irish Amateur Boxing Association . Michael <unk> won a gold medal and Wayne <unk> won a silver medal in the Barcelona Olympic Games and in 2008 Kenneth <unk> won a silver medal in the Beijing Games . Paddy Barnes secured bronze in those games and gold in the 2010 European Amateur Boxing Championships ( where Ireland came 2nd in the overall medal table ) and 2010 Commonwealth Games . Katie Taylor has won gold in every European and World championship since 2005 . In August 2012 at the Olympic Games in London Katie Taylor created history by becoming the first Irish woman to win a gold medal in boxing in the 60 kg lightweight . \\n Golf is very popular and golf tourism is a major industry attracting more than 240 @,@ 000 <unk> visitors annually . The 2006 Ryder Cup was held at The K Club in County Kildare . <unk> Harrington became the first <unk> since Fred Daly in 1947 to win the British Open at <unk> in July 2007 . He successfully defended his title in July 2008 before going on to win the <unk> Championship in August . Harrington became the first European to win the <unk> Championship in 78 years and was the first winner from Ireland . Three <unk> from Northern Ireland have been particularly successful . In 2010 , Graeme <unk> became the first Irish golfer to win the U.S. Open , and the first European to win that tournament since 1970 . Rory <unk> , at the age of 22 , won the 2011 U.S. Open , while Darren Clarke \\'s latest victory was the 2011 Open Championship at Royal St. George \\'s . In August 2012 , <unk> won his 2nd major championship by winning the <unk> Championship by a record margin of 8 shots . \\n \\n = = = = Recreation = = = = \\n \\n The west coast of Ireland , <unk> and Donegal Bay in particular , have popular surfing beaches , being fully exposed to the Atlantic Ocean . Donegal Bay is shaped like a funnel and catches west / south @-@ west Atlantic winds , creating good surf , especially in winter . Since just before the year 2010 , <unk> has hosted European championship surfing . <unk> diving is increasingly popular in Ireland with clear waters and large populations of sea life , particularly along the western seaboard . There are also many <unk> along the coast of Ireland , with some of the best wreck dives being in <unk> Head and off the County Cork coast . \\n With thousands of lakes , over 14 @,@ 000 kilometres ( 8 @,@ 700 mi ) of fish bearing rivers and over 3 @,@ 700 kilometres ( 2 @,@ 300 mi ) of coastline , Ireland is a popular angling destination . The temperate Irish climate is suited to sport angling . While salmon and trout fishing remain popular with anglers , salmon fishing in particular received a boost in 2006 with the closing of the salmon <unk> fishery . <unk> fishing continues to increase its profile . Sea angling is developed with many beaches mapped and <unk> , and the range of sea angling species is around 80 . \\n \\n = = = Food and drink = = = \\n \\n Food and cuisine in Ireland takes its influence from the crops grown and animals farmed in the island \\'s temperate climate and from the social and political circumstances of Irish history . For example , whilst from the Middle Ages until the arrival of the potato in the 16th century the dominant feature of the Irish economy was the herding of cattle , the number of cattle a person owned was equated to their social standing . Thus herders would avoid <unk> a milk @-@ producing cow . \\n For this reason , pork and white meat were more common than beef and thick fatty strips of salted <unk> ( or <unk> ) and the eating of salted butter ( i.e. a dairy product rather than beef itself ) have been a central feature of the diet in Ireland since the Middle Ages . The practice of bleeding cattle and mixing the blood with milk and butter ( not unlike the practice of the Maasai ) was common and black pudding , made from blood , grain ( usually barley ) and <unk> , remains a breakfast staple in Ireland . All of these influences can be seen today in the phenomenon of the \" breakfast roll \" . \\n The introduction of the potato in the second half of the 16th century heavily influenced cuisine thereafter . Great poverty encouraged a subsistence approach to food and by the mid @-@ 19th century the vast majority of the population <unk> with a diet of potatoes and milk . A typical family , consisting of a man , a woman and four children , would eat 18 stone ( 110 kg ) of potatoes a week . Consequently , dishes that are considered as national dishes represent a fundamental <unk> to cooking , such as the Irish <unk> , <unk> and cabbage , <unk> , a type of potato <unk> , or <unk> , a dish of <unk> potatoes and <unk> or cabbage . \\n Since the last quarter of the 20th century , with a re @-@ emergence of wealth in Ireland , a \" New Irish <unk> \" based on traditional ingredients incorporating international influences has emerged . This cuisine is based on fresh vegetables , fish ( especially salmon , trout , <unk> , <unk> and other <unk> ) , as well as traditional <unk> <unk> and the wide range of hand @-@ made <unk> that are now being produced across the country . The potato remains however a fundamental feature of this cuisine and the Irish remain the highest per capita consumers of potatoes in Europe . An example of this new cuisine is \" Dublin <unk> \" : lobster cooked in whiskey and cream . Traditional regional foods can be found throughout the country , for example <unk> in Dublin or <unk> in Cork , both a type of sausage , or <unk> , a <unk> white bread particular to Waterford . \\n Ireland once dominated the world \\'s market for whiskey , producing 90 % of the world \\'s whiskey at the start of the 20th century . However , as a consequence of <unk> during the prohibition in the United States ( who sold poor @-@ quality whiskey bearing Irish @-@ sounding names thus eroding the pre @-@ prohibition popularity for Irish brands ) and tariffs on Irish whiskey across the British Empire during the Anglo @-@ Irish Trade War of the 1930s , sales of Irish whiskey worldwide fell to a mere 2 % by the mid @-@ 20th century . In 1953 , an Irish government survey , found that 50 per cent of whiskey <unk> in the United States had never heard of Irish whiskey . \\n Irish whiskey , as researched in 2009 by the CNBC American broadcaster , remains popular domestically and has grown in international sales steadily over a few decades . Typically CNBC states Irish whiskey is not as <unk> as a Scotch <unk> , but not as sweet as American or Canadian <unk> . Whiskey forms the basis of traditional cream <unk> , such as <unk> , and the \" Irish coffee \" ( a cocktail of coffee and whiskey <unk> invented at <unk> flying @-@ boat station ) is probably the best @-@ known Irish cocktail . \\n <unk> , a kind of <unk> beer , particularly Guinness , is typically associated with Ireland , although historically it was more closely associated with London . Porter remains very popular , although it has lost sales since the mid @-@ 20th century to <unk> . Cider , particularly <unk> ( marketed in the Republic of Ireland as <unk> ) , is also a popular drink . Red <unk> , a soft @-@ drink , is consumed on its own and as a mixer , particularly with whiskey . \\n \\n'],\n",
       "      dtype=object)"
      ]
     },
     "execution_count": null,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df_train.iloc[-1].values"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We could tokenize it based on spaces to compare (as is usually done) but here we'll use the standard fastai tokenizer."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "splits = [list(range_of(df_train)), list(range(len(df_train), len(df_all)))]\n",
    "tfms = [attrgetter(\"text\"), Tokenizer.from_df(0), Numericalize()]\n",
    "dsets = Datasets(df_all, [tfms], splits=splits, dl_type=LMDataLoader)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "bs,sl = 104,72\n",
    "dls = dsets.dataloaders(bs=bs, seq_len=sl)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>text</th>\n",
       "      <th>text_</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>xxbos = xxmaj plunketts xxmaj creek ( xxmaj loyalsock xxmaj creek ) = \\n▁\\n▁ xxmaj plunketts xxmaj creek is an approximately xxunk - long ( 10.0 km ) tributary of xxmaj loyalsock xxmaj creek in xxmaj lycoming and xxmaj sullivan counties in the xxup u.s . state of xxmaj pennsylvania . xxmaj two unincorporated villages and a hamlet are on the creek , and its watershed drains 23.6 square miles ( 61</td>\n",
       "      <td>= xxmaj plunketts xxmaj creek ( xxmaj loyalsock xxmaj creek ) = \\n▁\\n▁ xxmaj plunketts xxmaj creek is an approximately xxunk - long ( 10.0 km ) tributary of xxmaj loyalsock xxmaj creek in xxmaj lycoming and xxmaj sullivan counties in the xxup u.s . state of xxmaj pennsylvania . xxmaj two unincorporated villages and a hamlet are on the creek , and its watershed drains 23.6 square miles ( 61 km2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>xxmaj the early stories follow the pattern of children 's books of orthodox education , such as those by xxmaj heinrich xxmaj hoffmann 's xxunk , that aim to teach the devastating consequences of bad behaviour . xxmaj busch did not assign value to his work , as he once explained to xxmaj heinrich xxmaj richter : \" i look at my things for what they are , as xxunk xxunk [</td>\n",
       "      <td>the early stories follow the pattern of children 's books of orthodox education , such as those by xxmaj heinrich xxmaj hoffmann 's xxunk , that aim to teach the devastating consequences of bad behaviour . xxmaj busch did not assign value to his work , as he once explained to xxmaj heinrich xxmaj richter : \" i look at my things for what they are , as xxunk xxunk [ toys</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>for some xxmaj egyptologists , such as xxunk xxunk , this failure contributed in no small part to the fall of the xxmaj old xxmaj kingdom , but others , including xxmaj strudwick , believe the reasons of the collapse must be sought elsewhere as the power of an administration official never approached that of the king . \\n▁ xxmaj the reforms of xxmaj djedkare xxmaj isesi played an important role in</td>\n",
       "      <td>some xxmaj egyptologists , such as xxunk xxunk , this failure contributed in no small part to the fall of the xxmaj old xxmaj kingdom , but others , including xxmaj strudwick , believe the reasons of the collapse must be sought elsewhere as the power of an administration official never approached that of the king . \\n▁ xxmaj the reforms of xxmaj djedkare xxmaj isesi played an important role in flourishing</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>aspect of the sport – they are the most basic level of track and field competition . xxmaj meetings are generally organised annually either under the patronage of an educational institution or sports club , or by a group or business that serves as the meeting promoter . xxmaj in the case of the former , athletes are selected to represent their club or institution . xxmaj in the case of privately</td>\n",
       "      <td>of the sport – they are the most basic level of track and field competition . xxmaj meetings are generally organised annually either under the patronage of an educational institution or sports club , or by a group or business that serves as the meeting promoter . xxmaj in the case of the former , athletes are selected to represent their club or institution . xxmaj in the case of privately run</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>by oracles communicating the gods ' will . \\n▁\\n▁ = = = xxmaj worship = = = \\n▁\\n▁ xxmaj official religious practices , which maintained maat for the benefit of all xxmaj egypt , were related to , but distinct from , the religious practices of ordinary people , who sought the gods ' help for their personal problems . \\n▁ xxmaj official religion involved a variety of rituals , based in</td>\n",
       "      <td>oracles communicating the gods ' will . \\n▁\\n▁ = = = xxmaj worship = = = \\n▁\\n▁ xxmaj official religious practices , which maintained maat for the benefit of all xxmaj egypt , were related to , but distinct from , the religious practices of ordinary people , who sought the gods ' help for their personal problems . \\n▁ xxmaj official religion involved a variety of rituals , based in temples</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>xxmaj rachel as one of the earliest and most prominent examples of the xxmaj jewish xxmaj american xxmaj princess stereotype on screen . xxmaj writing for the xxmaj university of xxmaj north xxmaj carolina at xxmaj chapel xxmaj hill , xxmaj alicia xxup r. xxunk also acknowledged xxmaj rachel 's initial xxmaj jewish xxmaj american xxmaj princess qualities , describing her as \" spoiled , dependent on her father 's money and</td>\n",
       "      <td>rachel as one of the earliest and most prominent examples of the xxmaj jewish xxmaj american xxmaj princess stereotype on screen . xxmaj writing for the xxmaj university of xxmaj north xxmaj carolina at xxmaj chapel xxmaj hill , xxmaj alicia xxup r. xxunk also acknowledged xxmaj rachel 's initial xxmaj jewish xxmaj american xxmaj princess qualities , describing her as \" spoiled , dependent on her father 's money and her</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>continues to attempt to xxunk . xxmaj the pair then encounter a xxmaj canadian who gives them his xxunk . \\n▁ xxmaj continuing north , they soon run out of gas , but receive help from the xxmaj aurora xxmaj boreanaz , who instructs them to stay at a nearby cabin . xxmaj the two survive the night in the cabin and set out on foot the next morning . xxmaj they</td>\n",
       "      <td>to attempt to xxunk . xxmaj the pair then encounter a xxmaj canadian who gives them his xxunk . \\n▁ xxmaj continuing north , they soon run out of gas , but receive help from the xxmaj aurora xxmaj boreanaz , who instructs them to stay at a nearby cabin . xxmaj the two survive the night in the cabin and set out on foot the next morning . xxmaj they finally</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>xxmaj general 's world as a labyrinth is xxunk by his constant return to cities and towns he has visited before : each location belongs to the past as well as to the present . xxmaj the xxmaj general in his xxmaj labyrinth xxunk the lines between xxunk in a man - made world and wandering in the natural world . \\n▁\\n▁ = = = xxmaj fate and love = = =</td>\n",
       "      <td>general 's world as a labyrinth is xxunk by his constant return to cities and towns he has visited before : each location belongs to the past as well as to the present . xxmaj the xxmaj general in his xxmaj labyrinth xxunk the lines between xxunk in a man - made world and wandering in the natural world . \\n▁\\n▁ = = = xxmaj fate and love = = = \\n▁\\n▁</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>direct measurement of the distance to a star ( 61 xxunk at 11.4 light - years ) was made in 1838 by xxmaj friedrich xxunk using the parallax technique . xxunk measurements demonstrated the vast separation of the stars in the heavens . xxmaj observation of double stars gained increasing importance during the 19th century . xxmaj in 1834 , xxmaj friedrich xxunk observed changes in the proper motion of the star</td>\n",
       "      <td>measurement of the distance to a star ( 61 xxunk at 11.4 light - years ) was made in 1838 by xxmaj friedrich xxunk using the parallax technique . xxunk measurements demonstrated the vast separation of the stars in the heavens . xxmaj observation of double stars gained increasing importance during the 19th century . xxmaj in 1834 , xxmaj friedrich xxunk observed changes in the proper motion of the star xxmaj</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "dls.show_batch()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Model"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "config = awd_lstm_lm_config.copy()\n",
    "config.update({'input_p': 0.6, 'output_p': 0.4, 'weight_p': 0.5, 'embed_p': 0.1, 'hidden_p': 0.2})\n",
    "model = get_language_model(AWD_LSTM, len(dls.vocab), config=config)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "opt_func = partial(Adam, wd=0.1, eps=1e-7)\n",
    "cbs = [MixedPrecision(clip=0.1), ModelResetter, RNNRegularizer(alpha=2, beta=1)]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "learn = Learner(dls, model, loss_func=CrossEntropyLossFlat(), opt_func=opt_func, cbs=cbs, metrics=[accuracy, Perplexity()])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: left;\">\n",
       "      <th>epoch</th>\n",
       "      <th>train_loss</th>\n",
       "      <th>valid_loss</th>\n",
       "      <th>accuracy</th>\n",
       "      <th>perplexity</th>\n",
       "      <th>time</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <td>0</td>\n",
       "      <td>5.541026</td>\n",
       "      <td>5.053756</td>\n",
       "      <td>0.241910</td>\n",
       "      <td>156.609619</td>\n",
       "      <td>02:27</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "learn.fit_one_cycle(1, 5e-3, moms=(0.8,0.7,0.8), div=10)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Full training"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "#learn.fit_one_cycle(90, 5e-3, moms=(0.8,0.7,0.8), div=10)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "jupytext": {
   "split_at_heading": true
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
